-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Make BFLB not use the SDK code #91977
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
6e0c76d
to
f2a098f
Compare
175cf3f
to
324da9a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR removes reliance on the Bouffalo Lab SDK code and replaces it with custom, in-tree drivers and build logic tailored for the BL60x series.
- Deletes legacy vector, IRQ, and common interrupt files in favor of new “e24” implementations
- Updates SOC headers and initialization routines to use
sys_read32
/sys_write32
instead of HAL wrappers - Overhauls the UART and pinctrl drivers, Kconfig, CMakeLists, and DTS bindings for custom flash partition support
Reviewed Changes
Copilot reviewed 42 out of 42 changed files in this pull request and generated 3 comments.
Show a summary per file
File | Description |
---|---|
soc/bflb/common/vector.S | Removed legacy reset vector assembly |
soc/bflb/common/soc_irq.S | Removed old IRQ handler assembly |
soc/bflb/common/soc_common_irq.c | Deleted common CLIC-based interrupt code |
soc/bflb/common/soc_common.h | Removed shared interrupt number definitions |
soc/bflb/common/e24/soc_irq_privileged.c | Added new privileged IRQ driver |
soc/bflb/common/e24/intc_clic.S | Added CLIC interrupt assembly hooks |
soc/bflb/common/e24/clic.h | Defined new CLIC CSR registers |
soc/bflb/common/CMakeLists.txt | Switched source inclusion to e24 under BL60x |
soc/bflb/bl60x/soc.h | Dropped SDK header include; now minimal SOC defs |
soc/bflb/bl60x/soc.c | Rewrote early init to use sys_read32 /sys_write32 |
soc/bflb/bl60x/CMakeLists.txt | Updated linker script and code relocation calls |
modules/hal_bouffalolab/{include,src,CMakeLists} | Removed SDK HAL headers/sources; simplified include paths |
drivers/serial/uart_bflb.c | Major rewrite to use register‐access APIs |
drivers/pinctrl/pinctrl_bflb[.c,_bl60x_70x.c] | Switched pinctrl logic to sys_read32 /sys_write32 |
drivers/clock_control/clock_control_bl60x.c | Increased NOP settle loops; moved settle call |
dts/riscv/bflb/bl60x.dtsi | Updated interrupt-parent to CLIC and flash dividers |
boards/**/*.dts | Replaced legacy SPI controller with flash partitions |
boards/**/support/*.cfg | Adjusted OpenOCD adapter speeds and reset regs |
Comments suppressed due to low confidence (1)
modules/hal_bouffalolab/CMakeLists.txt:6
- This block now only adds include directories and no longer compiles any HAL sources for Bouffalo Lab, likely disabling all HAL functionality. Restore
zephyr_library_sources
for enabled modules or adjust the condition.
if(CONFIG_SOC_FAMILY_BFLB)
@@ -4,8 +4,9 @@ | |||
|
|||
zephyr_include_directories(.) | |||
|
|||
if(CONFIG_SOC_SERIES_BL60X) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing vector.S, soc_irq.S, and soc_common_irq.c unconditionally and only adding e24 sources under CONFIG_SOC_SERIES_BL60X will break startup and IRQ handling for non-BL60X SoCs. Consider wrapping legacy sources in an else block or guarding removals similarly.
Copilot uses AI. Check for mistakes.
drivers/serial/uart_bflb.c
Outdated
PINCTRL_DT_INST_DEFINE(n); \ | ||
|
||
#define BFLB_UART_INIT(instance) \ | ||
PINCTRL_DT_INST_DEFINE(instance); \ | ||
PM_DEVICE_DT_INST_DEFINE(n, uart_bflb_pm_control); \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The BFLB_UART_INIT macro uses n
here instead of the macro parameter instance
, causing incorrect device definitions. Replace n
with instance
.
PM_DEVICE_DT_INST_DEFINE(n, uart_bflb_pm_control); \ | |
PM_DEVICE_DT_INST_DEFINE(instance, uart_bflb_pm_control); \ |
Copilot uses AI. Check for mistakes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
drivers/pinctrl/pinctrl_bflb.c
Outdated
+ BFLB_PINMUX_GET_SIGNAL(pins[i]) | ||
); | ||
|
||
if ((BFLB_PINMUX_GET_FUN(pins[i]) & 0xFF) == BFLB_PINMUX_FUN_INST_uart0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Masking with 0xFF
to extract function bits is a magic operation. Consider defining a named constant or helper to clarify the intent and ensure future compatibility.
if ((BFLB_PINMUX_GET_FUN(pins[i]) & 0xFF) == BFLB_PINMUX_FUN_INST_uart0) { | |
if ((BFLB_PINMUX_GET_FUN(pins[i]) & BFLB_PINMUX_FUN_MASK) == BFLB_PINMUX_FUN_INST_uart0) { |
Copilot uses AI. Check for mistakes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
Unless you have crystal ball or a oracle you should not try to guess people opinions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your sequence do not bisect. You must fixed.
#if defined(CONFIG_SOC_SERIES_BL60X) | ||
#include <zephyr/dt-bindings/pinctrl/bl60x-pinctrl.h> | ||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add an else to generate an error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
What does that mean here? |
d70de46
to
4a5f872
Compare
Each commit must build individually otherwise you broke the |
Yea it's easier to get once the english is fixed. Why do you think those commits are inseparable? They cannot be made to compile in separate PRs, they cannot be made to compile individually, would you rather I squash them? |
|
||
/* Disable output anyway */ | ||
regval = sys_read32(GLB_BASE + GLB_GPIO_CFGCTL34_OFFSET + ((real_pin >> 5) << 2)); | ||
regval &= ~(1 << (pin & 0x1f)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
real_pin?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
uh, yea? Would you prefer something like 'pin_number' ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nah I mean this line should be s/pin/real_pin/
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pin is already used as the input to the function, this is the pin number extracted from that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah no wait sorry, let me check. 1f should be function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You were correct, it's the output enable setting by pin number and it's a overflow prevention mask.
|
||
if (data->user_cb) { | ||
data->user_cb(dev, data->user_data); | ||
} | ||
/* clear interrupts that require ack*/ | ||
tmp = sys_read32(cfg->base_reg + UART_INT_CLEAR_OFFSET); | ||
tmp = tmp | UART_CR_URX_RTO_CLR; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there's more that needs clearing, e.g. you've enabled PCE so UART_CR_URX_PCE_CLR ; probably UART_CR_URX_END_CLR and UART_CR_UTX_END_CLR as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay no, deleted message was right but i looked at the wrong place UART_CR_URX_END_CLR and UART_CR_UTX_END_CLR 's interrupts should be masked and UART_CR_URX_PCE_CLR is handled in uart_bflb_err_check
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(masked = interrupt not thrown to CPU, but i think it was required for working?)
void riscv_clic_irq_priority_set(unsigned int irq, unsigned int prio, uint32_t flags) | ||
{ | ||
ARG_UNUSED(irq); | ||
ARG_UNUSED(prio); | ||
ARG_UNUSED(flags); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would be good to document why it's not being implemented? Or... should it be implemented?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should probably yes, will look into it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shell sample isnt working on this PR while it should anyway so i have some checks to do...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It works with debugger.... uuuurgh
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixing this has had the knock-off effect of somehow fixing the shell sample without the little wait I just added... Sometimes I really dont understand those chips...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
drivers/serial/uart_bflb.c
Outdated
tmp = sys_read32(cfg->base_reg + UART_STATUS_OFFSET); | ||
rc = tmp & UART_STS_UTX_BUS_BUSY; | ||
tmp = sys_read32(cfg->base_reg + UART_FIFO_CONFIG_1_OFFSET); | ||
rc += tmp & UART_TX_FIFO_CNT_MASK; | ||
return (rc > 0 ? 1 : 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think you have the logic backwards?
irq_tx_complete
returns 1 If nothing remains to be transmitted ; 0 If transmission is not completed.
tx is probably not complete if UART_STS_UTX_BUS_BUSY is set or if FIFO still contains data?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds like it yes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Note tx fifo count is inverted, it counts free bytes.
int uart_bflb_irq_tx_ready(const struct device *dev) | ||
{ | ||
const struct bflb_config *const cfg = dev->config; | ||
uint32_t tmp = 0; | ||
|
||
tmp = sys_read32(cfg->base_reg + UART_FIFO_CONFIG_1_OFFSET); | ||
return (tmp & UART_TX_FIFO_CNT_MASK) > 0; | ||
} | ||
|
||
int uart_bflb_irq_rx_ready(const struct device *dev) | ||
{ | ||
const struct bflb_config *const cfg = dev->config; | ||
uint32_t tmp = 0; | ||
|
||
tmp = sys_read32(cfg->base_reg + UART_FIFO_CONFIG_1_OFFSET); | ||
return (tmp & UART_RX_FIFO_CNT_MASK) > 0; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you've setup thresholds so raw count shouldn't be used? I think this should instead check if UART_URX_FIFO_INT / UART_UTX_FIFO_INT are set/pending.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These interrupts are masked, functionally it's the same (And there might have been a reason, interrupts gave me, and continue to give me, a lot of trouble on this platform, I wouldnt remember but it's possible there was issues doing it with the interrupt).
reg mstatus 0x7800 | ||
reg mie 0x0 | ||
# reg pc 0x23000000 | ||
reg mstatus 0x80000000 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bit 31 of mstatus is read-only?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure where that's from, I see the same, maybe 0x0 is more appropriate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
Reorganize and update soc folder files for SDK-independance Signed-off-by: Camille BAUD <mail@massdriver.space>
Reorganize and update hal_bouffalolab files for SDK-independance Signed-off-by: Camille BAUD <mail@massdriver.space>
Reorganize and update soc files for SDK-independance Signed-off-by: Camille BAUD <mail@massdriver.space>
Update driver file for SDK-independance Signed-off-by: Camille BAUD <mail@massdriver.space>
Update driver file for SDK-independance Signed-off-by: Camille BAUD <mail@massdriver.space>
mostly makes things a little bit safer Signed-off-by: Camille BAUD <mail@massdriver.space>
Update to new bl60x support and fixup openocd config Signed-off-by: Camille BAUD <mail@massdriver.space>
Update to new bl60x support Signed-off-by: Camille BAUD <mail@massdriver.space>
update to new bl60x support Signed-off-by: Camille BAUD <mail@massdriver.space>
|
What's in the title.
Large update that cannot be cut without breaking functionality.
Some drivers are getting entirely revamped, such as uart and pinctrl, do not consider those as updates of the older drivers, but rather new drivers (which is true to some large extent).